package com.flow.demo.framework.banner.core;

import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.util.ClassUtils;

import java.util.concurrent.TimeUnit;

/**
 * 项目启动成功后，提供文档相关的地址
 *
 * @author 福乐云
 */
@Slf4j
public class BannerApplicationRunner implements ApplicationRunner {

    @Override
    public void run(ApplicationArguments args) {
        ThreadUtil.execute(() -> {
            ThreadUtil.sleep(1, TimeUnit.SECONDS); // 延迟 1 秒，保证输出到结尾
            System.out.println("                                                                    \n" +
                    "                   $$$   $                  $$$                     \n" +
                    "                   $$$  $$$                 $$$                     \n" +
                    "        $$$$$$$$$$$$$$$$$$$$     $$$$$$$ $$$$$$$$$$$$        $$$    \n" +
                    "        $$$$$$$$$$$$$$$$$$$$     $$$$$$$ $$$$$$$$$$$$        $$$    \n" +
                    "        $$$        $$$             $$$      $$$   $$$        $$$    \n" +
                    "        $$$        $$$  $$$        $$$      $$$   $$$        $$$    \n" +
                    "        $$$$$$$$$$ $$$  $$$        $$$      $$$   $$$        $$$    \n" +
                    "        $$$    $$$ $$$ $$$         $$$     $$$    $$$        $$$    \n" +
                    "        $$$    $$  $$$$$$        $$$$$$$  $$$     $$$               \n" +
                    "        $$$ $ $$$  $$$$$    $    $$$$$$$ $$$      $$$        $$$    \n" +
                    "       $$$$ $$$$ $$$$$$$   $$           $$$  $$   $$$        $$$    \n" +
                    "      $$$$      $$$$  $$$$$$$          $$$    $$$$$$                \n" +
                    "                                                                    \n" +
                    "                                                                    \n" +
                    "                                --by 福乐云 [chéng gōng]    ");

        });
    }

    private static boolean isNotPresent(String className) {
        return !ClassUtils.isPresent(className, ClassUtils.getDefaultClassLoader());
    }

}
